package com.ptadmin.report.converter;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public class ReportConverterXml extends ReportConverterBase {

	private String xml;
	
//	@Override
//	protected Object buildItem(String[] row) {
//		// No need to build items for Xml.
//		return null;
//	}

//	@Override
//	protected Object doToObj() {
//		String json = org.json.XML.toJSONObject(xml).toString();
//		Gson gson = new Gson();
//		Object obj = gson.fromJson(json, new TypeToken<List<HashMap<String, String>>>(){}.getType());
//		return obj;
//	}
	
	@Override
	public String doToJson() {
		String json = org.json.XML.toJSONObject(xml).toString();
		return json;
	}
	
	@Override
	protected void doReadFrom(String path) {
		try {
			this.xml = FileUtils.readFileToString(new File(path));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
